<include file="public/layout"/>
<body style="background-color: #FFF; overflow: auto;">
<div id="toolTipLayer"
	 style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
	<form class="form-horizontal" id="adminHandle" action="" method="post">
		<div class="ncap-form-default">
			<dl class="row">
				<dt class="tit">
					<label ><em>*</em>城市选择</label>
				</dt>
				<dd class="opt">
					<select onchange="get_city(this,0)" id="province" name="province_id">
						<option value="0">选择省份</option>
						<volist name="provinces" id="province">
							<option value="{$key}" {$key==$data['province_id']?'selected':''}>{$province}</option>
						</volist>
					</select>
					<select onchange="get_area(this)" id="city" name="city_id">
						<option value="0">选择城市</option>
						<volist name="citys" id="city">
							<option value="{$key}" {$key==$data['city_id']?'selected':''}>{$city}</option>
						</volist>
					</select>
					<select id="district" name="district_id" >
					   <option value="0">选择区域</option>
						<volist name="countys" id="county">
							<option value="{$key}" {$key==$data['region_id']?'selected':''}>{$county}</option>
						</volist>
					</select>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label >起步价</label>
				</dt>
				<dd class="opt">
					<input style="width:100px ! important" type="text" name="start_init" value="{$data.start_init}" class="input-txt" placeholder="起始公里">KM ---
					<input style="width:100px ! important" type="text" name="val_init" value="{$data.val_init}" class="input-txt" placeholder="起步价">元
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label >是否开启起步价</label>
				</dt>
				<dd class="opt">
					<input type="radio" name="is_start" class="input-txt" value="1" style="width:20px ! important" <if condition="$data.is_start eq 1"> checked</if> >是 &nbsp;&nbsp;&nbsp;&nbsp;
					<input type="radio" name="is_start" value="0" class="input-txt" style="width:20px ! important" <if condition="$data.is_start eq 0"> checked</if> >否
				</dd>
			</dl>
			<div id="cons">
				<dl class="row">
					<dt class="tit">
						<label ><em></em>里程管理</label>
					</dt>
					<dd class="opt">
						<a type="button" class="ncap-btn-big ncap-btn-success" id="adds">添加</a>
					</dd>
				</dl>
				<volist name="$mile" id="v">
					<dl class="row">
						<dt class="tit">
							<label ></label>
						</dt>
						<dd class="opt">
							<input type="text" name="start[]" value="{$v.start}" class="input-txt" placeholder="起始公里" style="width:100px ! important">---
							<input style="width:100px ! important" type="text" name="end[]" value="{$v.end}" class="input-txt" placeholder="结束公里">KM
							<input style="width:100px ! important" type="text" name="val[]" value="{$v.value}" class="input-txt" placeholder="每公里单价">元
						</dd>
					</dl>
				</volist>
			</div>
			<dl class="row">
				<dt class="tit">
					<label ><em></em>城市首字母</label>
				</dt>
				<dd class="opt">
					<input type="text" name="first_name" value="{$data.first_name}" class="input-txt"> <span>  *只能输入一个字母</span>
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label ><em></em>每分钟(元)</label>
				</dt>
				<dd class="opt">
					<input type="text" name="minute" class="input-txt" value="{$data.minute}">
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label ><em></em>平台手续费(%)</label>
				</dt>
				<dd class="opt">
					<input type="text" name="plate_fee" class="input-txt" value="{$plate_fee}" placeholder="不要加%">
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label ><em></em>司机恶意退单罚款(元)</label>
				</dt>
				<dd class="opt">
					<input type="text" name="order_punish" class="input-txt" placeholder="司机恶意退单罚款" value="{$data.order_punish}">
				</dd>
			</dl>
			<dl class="row">
				<dt class="tit">
					<label ><em></em>乘客投诉罚款(元)</label>
				</dt>
				<dd class="opt">
					<input type="text" name="user_punish" class="input-txt" placeholder="乘客投诉罚款" value="{$data.user_punish}">
				</dd>
			</dl>
			<input type="hidden" name="zone_id" value="{$data.zone_id}">

			<div class="bot">
				<a href="JavaScript:void(0);" onclick="adsubmit();" class="ncap-btn-big ncap-btn-green" id="submitBtn">确认提交</a>
			</div>
		</div>
	</form>
</div>
<script type="text/javascript">
	// 判断输入框是否为空
	function adsubmit() {
		$('#adminHandle').submit();
	}

	$(document).ready(function () {
		$(document).on('click', '#adds', function () {
			var str = ' <dl class="row">                    <dt class="tit">                     <label ></label>                    </dt>                    <dd class="opt">                        <input type="text" name="start[]" class="input-txt"  placeholder="起始公里" style="width:100px ! important" >---<input style="width:100px ! important" type="text" name="end[]" class="input-txt"  placeholder="结束公里">KM   <input style="width:100px ! important" type="text" name="val[]" class="input-txt"  placeholder="每公里单价">元                    </dd>                </dl>';
			$("#cons").append(str);
		});
	});

	/**
	 * 获取城市
	 * @param t  省份select对象
	 */
    function get_city(t) {
        var parent_id = $(t).val();
        if (!parent_id > 0) {
            return;
        }
        $('#district').html("<option value=''>选择区域</option>");
        var url = "{:url('/admin/system/getRegion','level=3&parent_id=')}" + parent_id;
        ajax(url,'选择城市',$('#city'));
    }

	/**
	 * 获取地区
	 * @param t  城市select对象
	 */
    function get_area(t) {
        var parent_id = $(t).val(),district =$('#district') ;
        if (!parent_id > 0) {
            return;
        }
        district.html("<option value=''>选择区域</option>");
        var url = "{:url('/admin/system/getRegion','level=4&parent_id=')}" + parent_id;
        ajax(url,'选择区域',district);
    }

    function ajax(url,op,obj) {
        $.ajax({
            type: "GET",
            url: url,
            error: function (request) {
                alert("服务器繁忙, 请联系管理员!");
                return;
            },
            success: function (v) {
            	
                switch (v['status']){
                    case 1:
                        var s = "<option value=''>"+op+'</option>' + v['html'];
                        obj.html(s);
                        break;
                    default:
                        alert(v['msg']);
                        break;
                }
            }
        });
    }
</script>
</body>
</html>